package top.chengdongqing.mishop.user.favorite

import top.chengdongqing.mishop.entities.UserFavorite
import java.io.Serializable
import java.math.BigDecimal

data class FavoriteProductDTO(
    val id: Int?,
    val productId: Int,
    val productName: String?,
    val skuId: Int,
    val skuName: String?,
    val pictureUrl: String?,
    val price: BigDecimal?
) : Serializable {
    companion object {
        fun of(favorite: UserFavorite): FavoriteProductDTO {
            return FavoriteProductDTO(
                id = favorite.id,
                productId = favorite.product.id,
                productName = favorite.product.name,
                skuId = favorite.sku.id,
                skuName = favorite.sku.name,
                pictureUrl = favorite.sku.pictureUrl,
                price = favorite.sku.price
            )
        }
    }
}